package cn.iocoder.yudao.module.api.member.address.dto;

import cn.hutool.core.util.StrUtil;
import cn.iocoder.yudao.framework.region.RegionUtils;
import cn.iocoder.yudao.framework.region.vo.CountyVO;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

/**
 * 用户地址 Response DTO
 *
 * @author 芋道源码
 */
@Data
public class MemberAddressRespDTO extends CountyVO {

    @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
    private Long id;

    @Schema(description = "用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
    private Long userId;

    @Schema(description = "收件人名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "羡民")
    private String name;

    @Schema(description = "手机号", requiredMode = Schema.RequiredMode.REQUIRED, example = "15285116029")
    private String mobile;

    @Schema(description = "地区编号", deprecated = true)
    //@Deprecated
    private Integer areaId;

    @Deprecated
    @Schema(description = "地区名称，使用`fullAddress`代替", deprecated = true, example = "贵州省贵阳市南明区")
    private String areaName;

    @Schema(description = "收件详细地址", requiredMode = Schema.RequiredMode.REQUIRED, example = "花果园大街5号楼驰通集团公司")
    private String detailAddress;

    @Schema(description = "完整地址", requiredMode = Schema.RequiredMode.REQUIRED, example = "贵州省贵阳市南明区花果园大街5号楼驰通集团公司")
    private String fullAddress;

    @Schema(description = "是否默认地址", requiredMode = Schema.RequiredMode.REQUIRED, example = "true")
    private Boolean defaultStatus;

    @Schema(description = "是否点餐地址", requiredMode = Schema.RequiredMode.REQUIRED, example = "false")
    private Boolean isDine;

    @Override
    public String getCountyCode() {
        if (StrUtil.isEmpty(super.getCountyCode())) {
            return RegionUtils.convertRegionIdToCode(getAreaId());
        }
        return super.getCountyCode();
    }

    @SuppressWarnings("unused")
    public String getFullAddress() {
        return getProvinceName() + getCityName() + getCountyName() + getDetailAddress();
    }

    @Deprecated
    public String getAreaName() {
        return getProvinceName() + getCityName() + getCountyName();
    }

}
